package com.neusoft.neuiotms.dcom.converter.insurance;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.neusoft.bizcore.web.dto.AbstractConverter;
import com.neusoft.neuiotms.dcom.converter.hn.HnInspectionItemConverter;
import com.neusoft.neuiotms.dcom.dto.insurance.InsuranceInspectionTaskItemDTO;
import com.neusoft.neuiotms.dcom.model.insurance.InsuranceInspectionTaskItem;

@Component
public class InsuranceInspectionTaskItemConverter
        extends AbstractConverter<InsuranceInspectionTaskItem, InsuranceInspectionTaskItemDTO> {

    @Autowired
    private HnInspectionItemConverter hnInspectionItemConverter;

    @Override
    public InsuranceInspectionTaskItem toModel(final InsuranceInspectionTaskItemDTO dto) {

        final InsuranceInspectionTaskItem model = new InsuranceInspectionTaskItem();

        model.setException(dto.isException());
        model.setReason(dto.getReason());
        model.setValue(dto.getValue());
        model.setItem(this.hnInspectionItemConverter.toModel(dto.getItem()));

        return model;
    }

    @Override
    public InsuranceInspectionTaskItemDTO toDTO(final InsuranceInspectionTaskItem model, final boolean forListView) {

        final InsuranceInspectionTaskItemDTO dto = new InsuranceInspectionTaskItemDTO();

        dto.setException(model.isException());
        dto.setId(model.getId());
        dto.setReason(model.getReason());
        dto.setValue(model.getValue());
        dto.setItem(this.hnInspectionItemConverter.toDTO(model.getItem()));

        return dto;
    }

}
